//
//  ViewController.m
//  QRCode
//
//  Created by 宇周 on 15/11/16.
//  Copyright © 2015年 宇周. All rights reserved.
//

#import "ViewController.h"
#import "QRCodeGenerator.h"
@interface ViewController()<NSOpenSavePanelDelegate>
@property (unsafe_unretained) IBOutlet NSTextView *qrText;

@property (weak) IBOutlet NSImageView *qrImgV;

@end
@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

- (void)setRepresentedObject:(id)representedObject {
    [super setRepresentedObject:representedObject];

    // Update the view, if already loaded.
}

- (IBAction)processQRImage:(id)sender {
    if(self.qrText.string.length == 0)
    {
//        NSRunAlertPanel(@"提示", @"请输入内容", nil, nil, nil);
        NSAlert *alert = [[NSAlert alloc] init];
        [alert setMessageText:@"请输入内容"];
        [alert setAlertStyle:NSInformationalAlertStyle];
        [alert beginSheetModalForWindow:self.view.window completionHandler:^(NSModalResponse returnCode) {
            
        }];
        return ;
    }
    NSImage *qrI = [QRCodeGenerator qrImageForString:self.qrText.string imageSize:200];
    self.qrImgV.image = qrI;
}


@end
